Texture Mapping
Attaching painted, scanned, etc. images to objects is one of the most commonly used techniques in texturing. This chapter examines the basic tools and controls for texture mapping.
Level: Beginner/Medium
Example file: 'tutorprojects\material\mapping\can'
Cylinder mapping
In this tutorial we will create a 'real soft drink' can with some labels painted on it. For the sake of simplicity, the shape of the can may be just a simple cylinder.
1. Activate a top view and switch to the 'Analytic' tab of the toolbar. Select 'Cylinder' from the tool's menu. Then create the cylinder with two mouse clicks on the view window.
2. Activate a front view and stretch the length of the cylinder until the shape is suitable for a soft drink can. To do this you can use:

Modeling a can using the Analytic cylinder tool
3. Go to the Materials tab of the Select window. Choose 'New/From Template' from the popup menu. Using the file browser, select the template 'Image Maps/Color Map'. Click
'Open'.
4. Double click the icon of new 'Color Map' material to open the property window. Using the browse button at the right side of the 'File Name' gadget, select the sample texture 'realsoft.iff' from the 'textures' sub-folder of the Realsoft 3D installation directory. You can also use any other image if you like.

The color texture map material
5. Close the property window. The cylinder should be selected at this point; if not, click its wireframe to select it. Then drag & drop the 'Color map' material from the select window to the view window.
6. This drag & drop action automatically creates a cylinder mapping that matches the can. This happens because the 'Color Map' template is defined to behave this way (find out more about preferred mappings from the VSL tutorials). The cylinder mapping wraps the selected image nicely around the can and is a good starting point for further editing.
7. Slightly rotate the view downward from the front view and render it.

Cylinder mapping
As you see in the image above, there are some problems:
- The logo is upside down
- The bottom of the can shows strange artifacts
8. Mirroring the cylinder map horizontally solves the first problem. Go to the
Geometric objects tab of the Select window, open the hierarchy of the level 'Cylinder+Color Map' and select the mapping object 'Color Map(Color Map)'. Reactivate the front view. Select the Mirror tool from the
Transformation toolbar, click at the left side of the can, press the shift key and click a second time at the right side of the can. Shift locks the mirror axis to 45-degree steps, making it easy to mirror the mapping exactly vertically.
9. The artifacts at the bottom indicate accuracy problems. The cylinder map and the can have exactly the same length. It is impossible to say which one ends first, the texture mapping or the can (computers have only finite accuracy). Therefore, the rendering computations produce random results when trying to decide which one ends first. This is easy to fix. Scale the cylinder mapping to make it shorter using the scale handle and move it so that the mapping is in the middle of the can (see the image below). Render to verify that the mapping works well this time.


Cylinder mapping mirrored, shortened and centered
10. The logo texture goes all the way around the can which makes visualizing the image hard. So let us make it smaller. Open the property window of the mapping object and go to the 'Spec' tab (make sure that the mapping object is selected and the geometry objects tab is active on the select window). Change the 'Scale' gadget value to '0.25 0.5 1'. Then render again. The width of the logo has become one quarter and the height one half of the original size.

Adjusting the mapping scale
11. Keep the property window open but switch to the Materials tab on the Select window. The property window shows now the controls of the 'Color Map' material. Activate 'Tile X' and render again. The logo pattern now is repeated and travels around the can. You may close the property window now.

Tile X activated
12. The stripe of shrunk logo labels appears in the top half of the can, but how do you put it at the center of the can? You might have noticed that the mapping specific properties not only include 'Scale' but also 'Translate', 'Rotate', etc controls. You can use the 'Translate' gadget for accurate numeric positioning. However, the mapping geometry itself provides a more straightforward way to place the logo. Simply drag the cylinder mapping downward using its blue translate handle.
Note: using the unified tools of the toolbar, you can create a cylinder sector map:
Such a sector map allows intuitive control over the mapped area without the need to use numerical scale attributes.
Texture anti-aliasing
Let's experiment a bit more with the logo material created above.
Level: Beginner/Medium
Example file: tutorprojects\material\mapping\antialiasing
- Select the 'Cylinder+Color Map' from the object hierarchy and delete it.
- Go to the top view and zoom out very far. Select 'Rectangle' from the 'Analytic' tools menu and draw a rectangle which covers the whole view.
- Zoom back in to a normal scale. Activate the 'Materials' tab of the toolbar and choose the 'Parallel' mapping tool. Select the 'Color Map' material and draw a parallel map in the view window. The size of the map should be much smaller than the size of the rectangle.
- Set the view back to the front view. Go to the 'Light Sources tab' and activate the 'Ambient' light tool. Click Accept. Now the simple test scene is ready.
- Go to the 'Materials' section of the select window, activate the 'Color Map' material created in the previous tutorial and open its property window. 'Tile X' is already set but set 'Tile Y' as well.
- If the view window is in parallel projection, select 'Camera/Perspective' from the view's popup menu. Rotate the view window upwards and render. The result should look like this:

Bad anti-aliasing
The logo can be seen well in the front area, but the quality gets worse as the distance grows. Improving rendering quality helps a bit, but any reasonable quality cannot completely remove problems appearing far away from the camera. It is better to modify the material itself to fix this.
- In the material's property window check the 'advanced' option to see the internal structure of the material. The tree-like VSL diagram shows the structure of the material. You can see an item 'Color=Texture(Map coords)'. Select it by clicking it. The lower part of the property window now shows several tabs. Select the 'General' tab.

Adjusting anti-aliasing
- Set the 'Anti-aliasing' value to 1. It is a good default value to start with. The resolution of the logo image is some hundred pixels in both directions. When such a texture covers only few pixels in the final rendering many samples are needed to compute it. Optimally, the amount of samples should be the amount of details, i.e. the resolution of the image. Usually this would be very slow to compute. Setting the 'U samples' and 'V samples' to 10 tells the renderer to compute 100 (10*10) samples in the densest areas.
- Render the view to test the result. If the quality is not good enough at the horizon, increase the anti-aliasing value by one. If the densest areas are well rendered, but there are problematic areas closer to the camera, halve the 'Threshold' value from 1.0 to 0.5. The 'Threshold' defines the minimal texture density where the texture anti-aliasing starts. If these adjustments are not enough to give a good quality everywhere, continue to increase the U and V samples.

Good anti-aliasing achieved